package com.ruoyi.project.reportSystem.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.reportSystem.domain.WaiqingRecord;
import com.ruoyi.project.reportSystem.service.IWaiqingRecordService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 外勤打卡Controller
 * 
 * @author wangshuo
 * @date 2021-03-16
 */
@RestController
@RequestMapping("/reportSystem/waiqingrecord")
public class WaiqingRecordController extends BaseController
{
    @Autowired
    private IWaiqingRecordService waiqingRecordService;

    /**
     * 查询外勤打卡列表
     */
    @PreAuthorize("@ss.hasPermi('reportSystem:waiqingrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(WaiqingRecord waiqingRecord)
    {
        startPage();
        List<WaiqingRecord> list = waiqingRecordService.selectWaiqingRecordList(waiqingRecord);
        return getDataTable(list);
    }

    /**
     * 导出外勤打卡列表
     */
    @PreAuthorize("@ss.hasPermi('reportSystem:waiqingrecord:export')")
    @Log(title = "外勤打卡", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WaiqingRecord waiqingRecord)
    {
        List<WaiqingRecord> list = waiqingRecordService.selectWaiqingRecordList(waiqingRecord);
        ExcelUtil<WaiqingRecord> util = new ExcelUtil<WaiqingRecord>(WaiqingRecord.class);
        return util.exportExcel(list, "waiqingrecord");
    }

    /**
     * 获取外勤打卡详细信息
     */
    @PreAuthorize("@ss.hasPermi('reportSystem:waiqingrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(waiqingRecordService.selectWaiqingRecordById(id));
    }

    /**
     * 新增外勤打卡
     */
    @PreAuthorize("@ss.hasPermi('reportSystem:waiqingrecord:add')")
    @Log(title = "外勤打卡", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WaiqingRecord waiqingRecord)
    {
        return toAjax(waiqingRecordService.insertWaiqingRecord(waiqingRecord));
    }

    /**
     * 修改外勤打卡
     */
    @PreAuthorize("@ss.hasPermi('reportSystem:waiqingrecord:edit')")
    @Log(title = "外勤打卡", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WaiqingRecord waiqingRecord)
    {
        return toAjax(waiqingRecordService.updateWaiqingRecord(waiqingRecord));
    }

    /**
     * 删除外勤打卡
     */
    @PreAuthorize("@ss.hasPermi('reportSystem:waiqingrecord:remove')")
    @Log(title = "外勤打卡", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(waiqingRecordService.deleteWaiqingRecordByIds(ids));
    }
}
